package leetcode1;

import java.util.Arrays;

public class Day18 {

    public static void main(String[] args) {
        int[][] a = {{-2147483646,-2147483645},{2147483646,2147483647}};
        //findMinArrowShots(a);
    }
    public int findMinArrowShots(int[][] points) {
        //1.排序
        Arrays.sort(points,(a,b)->{
            return a[0]>b[0]?1:-1;
        });
        //2.求区间的并集
        int ret=0, right=points[0][1];
        for(int i=1;i<points.length;i++) {
            int a=points[i][0],b=points[i][1];
            if(a <= right) {
                //重叠区间+1
                right=Math.min(right,b);
            }else {
                ret++;//箭+1
                right=b;
            }
        }
        return ++ret;

    }
}
